package org.dbstar.scheduler.control.db.job;

import java.io.File;
import java.sql.Types;

import org.dbstar.scheduler.beans.Job;
import org.dbstar.scheduler.job.JobStatus;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlParameter;


/**
 * 按照Identifier查询Job
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-4-28
 */
public class JobQueryFirstReady extends JobQuery {
	public JobQueryFirstReady(JdbcTemplate jdbcTemplate, File resultRoot) {
		super(jdbcTemplate, "WHERE STATUS = ? ORDER BY SYSTEM_IDENTIFIER, SEQUENCE LIMIT 1", resultRoot);
		declareParameter(new SqlParameter("STATUS", Types.VARCHAR));
	}

	public Job findFirstReady() throws DataAccessException {
		return super.findObject(JobStatus.ready.name());
	}
}
